package org.example.extension.beanPostProcessor;

import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class CustomBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        // custom logic before initialization
        if(bean instanceof BeanPostProcessorDemo) {
            System.out.println("CustomBeanPostProcessor.postProcessBeforeInitialization: BeanPostProcessorDemo");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        // custom logic after initialization
        if(bean instanceof BeanPostProcessorDemo) {
            System.out.println("CustomBeanPostProcessor.postProcessAfterInitialization: BeanPostProcessorDemo");
        }
        return bean;
    }
}
